package br.com.gscorp.bankLion.security;

import java.util.Collection;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import br.com.gscorp.bankLion.entity.TipoUsuario;
import br.com.gscorp.bankLion.entity.Usuario;

public class BankLionUserDetails extends User{

	private Long id;
	private String nome;
	private TipoUsuario tipoUsuario;
	
	public BankLionUserDetails(Usuario usuario, boolean enabled,
			boolean accountNonExpired, boolean credentialsNonExpired,
			boolean accountNonLocked,
			Collection<? extends GrantedAuthority> authorities) {
		super(usuario.getEmail(), usuario.getSenha(), enabled, accountNonExpired, credentialsNonExpired,
				accountNonLocked, authorities);
		
		this.nome = usuario.getNome();
		this.id = usuario.getId();
		this.tipoUsuario = usuario.getTipoUsuario();
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public TipoUsuario getTipoUsuario() {
		return tipoUsuario;
	}
	public void setTipoUsuario(TipoUsuario tipoUsuario) {
		this.tipoUsuario = tipoUsuario;
	}
	
	@JsonIgnore
	public Boolean isAdministrador(){
		if(this.tipoUsuario.equals(TipoUsuario.ADMINISTRADOR)){
			return true;
		} else {
			return false;
		}
	}
	
	@JsonIgnore
	public Boolean isUsuario(){
		if(this.tipoUsuario.equals(TipoUsuario.USUARIO)){
			return true;
		} else {
			return false;
		}
	}
	
	/**
	 * @return the perfilAgente
	 */
	private static final long serialVersionUID = 555221185842874775L;
	

}
